#include<bits/stdc++.h>
using namespace std;

const int N = 1e6 + 5;
int T,n,m,L,top;

long long d[N],v[N],a[N],p[N],V;
struct bj{
    int l,r;
}fg[N];

int fdh(int x){
    int l = 1,r = m,ans = m;
    while(l<=r){
        int mid = (l+r)/2;
        if(p[mid] >= x){
            ans = mid;
            r = mid - 1;
        }
        else l = mid + 1;
    }
    return ans;
}

double qv(long long v0,long long a,long long s){
    return sqrt(v0*v0+2*a*s);
}

int fdd(int x){
    int l = fdh(d[x]),r = m,ans = m;
    while(l<=r){
        int mid = (l+r)/2;
        if(qv(v[x],a[x],p[mid]-d[x]) > V){
            ans = mid;
            r = mid - 1;
        }
        else l = mid + 1;
    }
    return ans;
}

int fdx(int x){
     int l = fdh(d[x]),r = m,ans = -1;
    while(l<=r){
        int mid = (l+r)/2;
        if(v[x]*v[x]+2*a[x]*(p[mid]-d[x]) >= 0&&qv(v[x],a[x],p[mid]-d[x]) > V){
            l = mid + 1;
            ans = mid;
        }
        else r = mid - 1;
    }
    return ans;

}
bool cl(int i){
    if(a[i]>0){
        if(v[i]>V){
            if(d[i]<=p[m]){
                fg[++top].l = fdh(d[i]);
                fg[top].r = m;
            }
        }
        else{
            if(qv(v[i],a[i],p[m]-d[i]) > V){
                fg[++top].l = fdd(i);
                fg[top].r = m;
            }
        }
    }
    if(a[i]==0){
        if(v[i]>V){
            if(d[i]<=p[m]){
                fg[++top].l = fdh(d[i]);
                fg[top].r = m;
            }
        }
    }
    if(a[i]<0){
        if(v[i]>V){

            if(v[i]*v[i]+2*a[i]*(p[m]-d[i]) > 0 && qv(v[i],a[i],p[m]-d[i]) > V){
                fg[++top].l = fdh(d[i]);
                fg[top].r = m;
            }
            else{
                int k = fdx(i);
                if(k != -1){
                    fg[++top].l = fdh(d[i]);
                    fg[top].r = k;
                }
            }
        }
    }
}




bool cmp(bj a,bj b){
    return ((a.r!=b.r)?a.r < b.r:a.l<b.l);
}
void solve(){
    top = 0;
    scanf("%d%d%d%lld",&n,&m,&L,&V);
    for(int i = 1;i<=n;i++){
        scanf("%lld%lld%lld",&d[i],&v[i],&a[i]);
    }
    for(int i = 1;i<=m;i++){
        scanf("%lld",&p[i]);
    }

    for(int i = 1;i<=n;i++){
        cl(i);
    }
    sort(fg+1,fg+top+1,cmp);
    printf("%d ",top);
    int ans = 0;

    for(int i = 1;i<=top;i++){
        ans ++;
        int jz = fg[i].r;
        while(fg[i+1].l<=jz&&i+1<=top)i++;
    }
    printf("%d\n",m-ans);
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    scanf("%d",&T);
    while(T--){
        solve();
    }
    return 0;
}
